import request from '@/utils/request'

export function getList(params) {
  return request({
    url: `/device`,
    method: 'get',
    params,
  })
}

export function getOne(serialno, params) {
  return request({
    url: `/device/${serialno}`,
    method: 'get',
    params,
  })
}

export function doAdd(data) {
  return request({
    url: `/device`,
    method: 'post',
    data,
  })
}

export function doEdit(serialno, data) {
  return request({
    url: `/device/${serialno}`,
    method: 'patch',
    data,
  })
}

export function doDelete(serialno) {
  return request({
    url: `/device/${serialno}`,
    method: 'delete',
  })
}

export function doMultiDelete(serialnos) {
  return request({
    url: `/device/multserialnoelete`,
    method: 'delete',
    data: { serialnos },
  })
}

export function doCommand(serialno, data) {
  return request({
    url: `/device/${serialno}/command`,
    method: 'post',
    data,
  })
}

export function doStates(serialno, params) {
  return request({
    url: `/device/${serialno}/states`,
    method: 'get',
    params,
  })
}

export function doUsual(data) {
  return request({
    url: `/device/usual`,
    method: 'post',
    data,
  })
}

export function doComm(data) {
  return request({
    url: `/device/comm`,
    method: 'post',
    data,
  })
}

export function doFind(serialno, params) {
  return request({
    url: `/device/${serialno}/find`,
    method: 'get',
    params,
  })
}
